//
//  LSRNavController.m
//  BaiSiProject
//
//  Created by lshenrong on 16/7/3.
//  Copyright © 2016年 lshenrong. All rights reserved.
//

#import "LSRNavController.h"

@interface LSRNavController ()<UIGestureRecognizerDelegate>

@end

@implementation LSRNavController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //    self.interactivePopGestureRecognizer.delegate=self;
    
    //
    //    NSLog(@"%@",self.interactivePopGestureRecognizer.delegate);
    //
    //    NSLog(@"%@",self.interactivePopGestureRecognizer);
    //干掉系统的边缘手势（练习不实现用出现问题）
     self.interactivePopGestureRecognizer.enabled=NO;
    
    UIPanGestureRecognizer *pan=[[UIPanGestureRecognizer alloc] initWithTarget:self.interactivePopGestureRecognizer.delegate action:@selector(handleNavigationTransition:)];
    //添加手势
    [self.view addGestureRecognizer:pan];
    
    //模仿系统，设置代理，实现代理方法.，这点容易忘记
    pan.delegate=self;
}

+(void)load

{    //这个方法在被抛弃的方法里面找
    UINavigationBar *bar=[UINavigationBar appearanceWhenContainedIn:self,nil];
    
    //格式字典
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    
    //设置字体的大小
    dict[NSFontAttributeName]=[UIFont systemFontOfSize:20];
    
    [bar setTitleTextAttributes:dict];
    
    
}
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{       
    [super pushViewController:viewController animated:YES];//重写父类的方法别忘了super
    
    //    self.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithimage:[UIImage imageNamed:@"navigationButtonReturn"] highlightImage:[UIImage imageNamed:@"navigationButtonReturnClick"] Target:self action:@selector(returnClick:) forControlEvents:UIControlEventTouchUpInside string:@"发现"];
    //从setting控制器移植，self改为 viewController,统一布置返回按钮
    //如果super写在if后面，self.childViewControllers.count>0就可以了
    if (self.childViewControllers.count>1) {
        //子控制器数量两个以上进行部署，跟控制器的“发现按钮”就不会出现了
        viewController.navigationItem.leftBarButtonItem=[UIBarButtonItem itemWithimage:[UIImage imageNamed:@"navigationButtonReturn"] highlightImage:[UIImage imageNamed:@"navigationButtonReturnClick"] Target:self action:@selector(returnClick:) forControlEvents:UIControlEventTouchUpInside string:@"发现"];
//        viewController.hidesBottomBarWhenPushed=YES;//这句要写在push之前,隐藏所有的底部条
        
    }
    
    

//    LSR__fnc__;
}

-(void)returnClick:(UIButton *)btn
{

    [self popViewControllerAnimated:YES];

}
#pragma mark --- UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    //非跟控制器时候，触发手势才有效
    return self.childViewControllers.count>1;
    
}



@end
